import Vue from 'vue';
import Router from 'vue-router';
import IndexView from '@/components/Index';
import BaiduView from '@/components/baidu/Baidu.vue';
import GaodeView from '@/components/gaode/Gaode.vue';
import EhlView from '@/components/ehl/Ehl.vue';

Vue.use(Router);

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Index',
      components: {
        app: IndexView
      }
    },
    {
      path: '/baidu',
      name: 'Baidu',
      components: {
        app: BaiduView
      },
      children: [
        {
          path: '/',
          redirect: to => {
            return '/ivista';
          }
        },
        {
          path: '/ivista',
          name: 'Ivista',
          components: {
            baiduMap: () => import('@/components/baidu/Ivista.vue')
          }
        },
        {
          path: '/tool',
          name: 'BaiduTool',
          components: {
            baiduMap: () => import('@/components/baidu/Tool.vue')
          }
        }
      ]
    },
    {
      path: '/gaode',
      name: 'Gaode',
      components: {
        app: GaodeView
      },
      children: [
        {
          path: '/',
          redirect: to => {
            return '/gaode/demo1';
          }
        },
        {
          path: '/gaode/demo1',
          name: 'GaodeDemo1',
          components: {
            gaodeMap: () => import('@/components/gaode/GaodeDemo1.vue')
          }
        },
        {
          path: '/gaode/demo2',
          name: 'GaodeDemo2',
          components: {
            gaodeMap: () => import('@/components/gaode/GaodeDemo2.vue')
          }
        }
      ]
    },
    {
      path: '/ehl',
      name: 'Ehl',
      components: {
        app: EhlView
      },
      children: [
        {
          path: '/',
          redirect: to => {
            return '/ehl/demo1';
          }
        },
        {
          path: '/ehl/demo1',
          name: 'EhlDemo1',
          components: {
            ehlMap: () => import('@/components/ehl/EhlDemo1.vue')
          }
        }
      ]
    }
  ]
});
